var html;

























var cont = 1;

function addDinamicHtml(dinamicHtml){

    $('.'+dinamicHtml.classOnClick+':last').click(function() {


         var rep = replaceDinamiclyIds(dinamicHtml)
         dinamicHtml = rep[0];
         newText = rep[1];
        

        if(dinamicHtml.addBefore){
            // $('#'+ dinamicHtml.idInsertCode)
             $('#'+dinamicHtml.idInsertCode).before(newText);
        }else{
             //$('#'+ dinamicHtml.idInsertCode).
             $('#'+dinamicHtml.idInsertCode).after(newText);
        }



            $('#'+dinamicHtml.idCount).attr('value', dinamicHtml.firstId)



       addDinamicHtml(dinamicHtml)

          $(this).attr('src',dinamicHtml.removeImagePath)
        $(this).attr('class','remove')
        $(this).unbind('click');
        //$(this).parents().filter('table').find('input').attr("disabled", true);
        $(this).click(function() {
            $(this).parents().filter('.'+dinamicHtml.removeParent).remove();
        });

       //extraFunctions($(this), dinamicHtml.removeImagePath,dinamicHtml.removeParent);
       dinamicHtml.functions(dinamicHtml.firstId);

       //extraFunctions();
      // dinamicHtml.functions();

    });

}


function replaceDinamiclyIds(dinamicHtml){
   
    var htmlEdited =  dinamicHtml.innerHtml;

    for(i = 0; i< dinamicHtml.idsToModify.length; i++){
       

       // dinamicHtml.innerHtml =
          htmlEdited = htmlEdited.replace(dinamicHtml.idsToModify[i].originalId ,dinamicHtml.idsToModify[i].newId + dinamicHtml.firstId);
 

       
    }

    dinamicHtml.firstId = dinamicHtml.firstId + 1;







var ret = new Array();
ret[0] = dinamicHtml;
ret[1] = htmlEdited;
    return ret;
}


function fillColorimetryValues(){


    $('#colorimetryId').change(function() {
        var colorimetryId = $('#colorimetryId').attr('value');


    });



}